package com.freshcity.component
{
	import com.freshcity.component.container.Component;
	import com.freshcity.core.MainScene;
	import com.freshcity.graphics.WaitStatusRender;
	import com.freshcity.manager.CommunicatorManager;
	import com.freshcity.core.OpCodes;
	import com.greensock.TimelineMax;
	import com.greensock.TweenLite;
	
	import flash.display.Sprite;

	public class WaitIcon extends Component
	{
		private var _room:*;

		private var back:WaitStatusRender;
		private var _synch:Boolean;
		
		private var waitNum:int;

		public function WaitIcon(xpos:Number=0,ypos:Number=0)
		{
			this.mouseEnabled = false;
			this.tabEnabled = false;
			super(null,xpos,ypos);
		}
		
		override protected function addChildren():void
		{
			super.addChildren();
			back=new WaitStatusRender();
			addChild(back);
		}
		
		override public function draw():void
		{
			super.draw();
		}

		public function get isSynch():Boolean
		{
			return _synch;
		}
		
		public function set isSynch(value:Boolean):void
		{
			_synch=value;
			if (_synch)
			{
				main.commu.register(OpCodes.WAITER_NUM, onUpdateWaiterNum);
			}
			else
			{
				main.commu.unRegister(OpCodes.WAITER_NUM);
			}
		}
		
		private function onUpdateWaiterNum(data:*):void
		{
			back.femaleWaitAmt.text = data.femaleNum;
			back.maleWaitAmt.text = data.maleNum;
		}

		public function get room():*
		{
			return this._room;
		}

		public function set room(value:*):void
		{
			this._room = value;
			this.back.femaleWaitAmt.text = room.femaleNum;
			this.back.maleWaitAmt.text = room.maleNum;
		}
		
	}
}
